package net.mcreator.backrooma.entity.renderer;

import net.minecraftforge.fml.client.registry.RenderingRegistry;
import net.minecraftforge.eventbus.api.SubscribeEvent;
import net.minecraftforge.client.event.ModelRegistryEvent;
import net.minecraftforge.api.distmarker.OnlyIn;
import net.minecraftforge.api.distmarker.Dist;

import net.minecraft.util.ResourceLocation;
import net.minecraft.entity.Entity;
import net.minecraft.client.renderer.texture.OverlayTexture;
import net.minecraft.client.renderer.model.ModelRenderer;
import net.minecraft.client.renderer.entity.model.EntityModel;
import net.minecraft.client.renderer.entity.layers.LayerRenderer;
import net.minecraft.client.renderer.entity.MobRenderer;
import net.minecraft.client.renderer.entity.IEntityRenderer;
import net.minecraft.client.renderer.RenderType;
import net.minecraft.client.renderer.IRenderTypeBuffer;

import net.mcreator.backrooma.entity.LittleBlackWireEntity;

import com.mojang.blaze3d.vertex.IVertexBuilder;
import com.mojang.blaze3d.matrix.MatrixStack;

@OnlyIn(Dist.CLIENT)
public class LittleBlackWireRenderer {
	public static class ModelRegisterHandler {
		@SubscribeEvent
		@OnlyIn(Dist.CLIENT)
		public void registerModels(ModelRegistryEvent event) {
			RenderingRegistry.registerEntityRenderingHandler(LittleBlackWireEntity.entity, renderManager -> {
				return new MobRenderer(renderManager, new ModelBlackWiredMan(), 0.5f) {
					{
						this.addLayer(new GlowingLayer<>(this));
					}

					@Override
					public ResourceLocation getEntityTexture(Entity entity) {
						return new ResourceLocation("backrooma:textures/blackwiredman.png");
					}
				};
			});
		}
	}

	@OnlyIn(Dist.CLIENT)
	private static class GlowingLayer<T extends Entity, M extends EntityModel<T>> extends LayerRenderer<T, M> {
		public GlowingLayer(IEntityRenderer<T, M> er) {
			super(er);
		}

		public void render(MatrixStack matrixStackIn, IRenderTypeBuffer bufferIn, int packedLightIn, T entitylivingbaseIn, float limbSwing,
				float limbSwingAmount, float partialTicks, float ageInTicks, float netHeadYaw, float headPitch) {
			IVertexBuilder ivertexbuilder = bufferIn.getBuffer(RenderType.getEyes(new ResourceLocation("backrooma:textures/blackwiredman.png")));
			this.getEntityModel().render(matrixStackIn, ivertexbuilder, 15728640, OverlayTexture.NO_OVERLAY, 1, 1, 1, 1);
		}
	}

	// Made with Blockbench 3.9.3
	// Exported for Minecraft version 1.15 - 1.16 with MCP mappings
	// Paste this class into your mod and generate all required imports
	public static class ModelBlackWiredMan extends EntityModel<Entity> {
		private final ModelRenderer Head;
		private final ModelRenderer cube_r2;
		private final ModelRenderer cube_r1;
		private final ModelRenderer cube_r1_r1;
		private final ModelRenderer rightleg;
		private final ModelRenderer leftleg;
		private final ModelRenderer Body;
		private final ModelRenderer cube_r3;
		private final ModelRenderer cube_r4;
		private final ModelRenderer leftFoot;
		private final ModelRenderer RightFoot;

		public ModelBlackWiredMan() {
			textureWidth = 64;
			textureHeight = 64;
			Head = new ModelRenderer(this);
			Head.setRotationPoint(0.0F, 24.0F, 0.0F);
			Head.setTextureOffset(0, 0).addBox(-4.0F, -29.0F, -3.0F, 7.0F, 6.0F, 6.0F, 0.0F, true);
			cube_r2 = new ModelRenderer(this);
			cube_r2.setRotationPoint(4.0F, 15.0F, 0.0F);
			setRotationAngle(cube_r2, 0.0F, 0.0F, 0.6981F);
			cube_r2.setTextureOffset(25, 28).addBox(-4.0F, -1.0F, 0.0F, 5.0F, 2.0F, 3.0F, 0.0F, false);
			cube_r1 = new ModelRenderer(this);
			cube_r1.setRotationPoint(-9.0F, 0.0F, 0.0F);
			cube_r2.addChild(cube_r1);
			setRotationAngle(cube_r1, 0.0F, 0.0F, -0.7854F);
			cube_r1_r1 = new ModelRenderer(this);
			cube_r1_r1.setRotationPoint(5.0F, 9.0F, 0.0F);
			cube_r1.addChild(cube_r1_r1);
			setRotationAngle(cube_r1_r1, 0.0F, 0.0F, -0.6545F);
			cube_r1_r1.setTextureOffset(0, 30).addBox(-5.0F, -8.0F, 0.0F, 5.0F, 2.0F, 3.0F, 0.0F, false);
			rightleg = new ModelRenderer(this);
			rightleg.setRotationPoint(5.0F, 15.0F, 0.0F);
			rightleg.setTextureOffset(14, 19).addBox(-13.0F, 0.0F, 0.0F, 4.0F, 9.0F, 3.0F, 0.0F, false);
			leftleg = new ModelRenderer(this);
			leftleg.setRotationPoint(5.0F, 15.0F, 0.0F);
			leftleg.setTextureOffset(0, 18).addBox(-1.0F, 0.0F, 0.0F, 4.0F, 9.0F, 3.0F, 0.0F, false);
			Body = new ModelRenderer(this);
			Body.setRotationPoint(0.0F, 24.0F, 0.0F);
			Body.setTextureOffset(26, 8).addBox(-4.0F, -18.0F, 5.0F, 7.0F, 2.0F, 1.0F, 0.0F, false);
			cube_r3 = new ModelRenderer(this);
			cube_r3.setRotationPoint(0.0F, -17.0F, 5.0F);
			Body.addChild(cube_r3);
			setRotationAngle(cube_r3, 0.5672F, 0.0F, 0.0F);
			cube_r3.setTextureOffset(26, 0).addBox(-3.0F, -7.0F, 0.0F, 5.0F, 7.0F, 1.0F, 0.0F, false);
			cube_r4 = new ModelRenderer(this);
			cube_r4.setRotationPoint(0.0F, -12.0F, 0.0F);
			Body.addChild(cube_r4);
			setRotationAngle(cube_r4, -0.6545F, 0.0F, 0.0F);
			cube_r4.setTextureOffset(28, 19).addBox(-3.0F, -7.0F, 1.0F, 5.0F, 7.0F, 1.0F, 0.0F, false);
			leftFoot = new ModelRenderer(this);
			leftFoot.setRotationPoint(-4.0F, 15.0F, 0.0F);
			leftFoot.setTextureOffset(17, 13).addBox(-5.0F, 8.0F, -1.0F, 6.0F, 1.0F, 5.0F, 0.0F, false);
			RightFoot = new ModelRenderer(this);
			RightFoot.setRotationPoint(0.0F, 24.0F, 0.0F);
			RightFoot.setTextureOffset(0, 12).addBox(3.0F, -1.0F, -1.0F, 6.0F, 1.0F, 5.0F, 0.0F, false);
		}

		@Override
		public void render(MatrixStack matrixStack, IVertexBuilder buffer, int packedLight, int packedOverlay, float red, float green, float blue,
				float alpha) {
			Head.render(matrixStack, buffer, packedLight, packedOverlay);
			cube_r2.render(matrixStack, buffer, packedLight, packedOverlay);
			rightleg.render(matrixStack, buffer, packedLight, packedOverlay);
			leftleg.render(matrixStack, buffer, packedLight, packedOverlay);
			Body.render(matrixStack, buffer, packedLight, packedOverlay);
			leftFoot.render(matrixStack, buffer, packedLight, packedOverlay);
			RightFoot.render(matrixStack, buffer, packedLight, packedOverlay);
		}

		public void setRotationAngle(ModelRenderer modelRenderer, float x, float y, float z) {
			modelRenderer.rotateAngleX = x;
			modelRenderer.rotateAngleY = y;
			modelRenderer.rotateAngleZ = z;
		}

		public void setRotationAngles(Entity e, float f, float f1, float f2, float f3, float f4) {
		}
	}

}
